package com.base.dao.service.impl;

import com.base.dao.mapper.BaseMapper;
import com.base.dao.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class BaseServiceImpl<M extends BaseMapper<T>,T> implements BaseService<T> {
    @Autowired
    protected  M baseMapper;

    @Override
    public T selectOne(T record) {
        return baseMapper.selectOne(record);
    }

    @Override
    public List<T> select(T record) {
        return baseMapper.select(record);
    }

    @Override
    public int selectCount(T record) {
        return baseMapper.selectCount(record);
    }

    @Override
    public T selectByPrimaryKey(Object key) {
        return baseMapper.selectByPrimaryKey(key);
    }

    @Override
    public List<T> selectByExample(Object example) {
        return baseMapper.selectByExample(example);
    }

    @Override
    public boolean insert(T record) {
        return baseMapper.insert(record) >0 ? true : false;
    }

    @Override
    public boolean insertSelective(T record) {
        return baseMapper.insertSelective(record) >0 ? true : false;
    }

    @Override
    public boolean delete(T record) {
        return baseMapper.delete(record) >0 ? true : false;
    }

    @Override
    public boolean deleteByPrimaryKey(Object key) {
        return baseMapper.deleteByPrimaryKey(key) >0 ? true : false;
    }

    @Override
    public boolean updateByPrimaryKey(T record) {
        return baseMapper.updateByPrimaryKey(record) >0 ? true : false;
    }

    @Override
    public boolean updateByPrimaryKeySelective(T record) {
        return baseMapper.updateByPrimaryKeySelective(record)  >0 ? true : false;
    }
}
